package com.boc.ewr.bcimp.service.impl;

import com.boc.ewr.bcimp.entity.CaUnrtnList;
import com.boc.ewr.bcimp.mapper.CaUnrtnListMapper;
import com.boc.ewr.bcimp.service.ICaUnrtnListService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;

/**
 * @Description: 未回清单
 * @Author: jeecg-boot
 * @Date:   2023-04-20
 * @Version: V1.0
 */
@Service
@Slf4j
public class CaUnrtnListServiceImpl extends ServiceImpl<CaUnrtnListMapper, CaUnrtnList> implements ICaUnrtnListService {

    @Autowired
    CaUnrtnListMapper caUnrtnListMapper;
    //批量导入
    @Transactional
    public boolean initSaveBatch(Collection<CaUnrtnList> entityList, Boolean flag){

        if(entityList.isEmpty() || entityList.size() == 0){
            return false;
        }
        long start = System.currentTimeMillis();
        //以最后一次导入为准，清空原数据
        if (flag) {
            caUnrtnListMapper.delete(null);
        }
        log.info("清空未回清单数据, 所耗时间:" + (System.currentTimeMillis() - start) + "ms");
        //保存数据
        boolean result = saveBatch(entityList, DEFAULT_BATCH_SIZE);
        return result;
    }

}
